var xhr;
function checkname(){
	var idSubject = document.getElementById("idSubject");
	var id = 0;
	var name = document.getElementById("subjectname").value;
	if(idSubject != null){//修改专题
		id = parseInt(idSubject.value);
		var url = "json/plantManager-checkSubjectName.html?subjectName=" + name + "&idSubject=" + id ;
		xhr = null;
		xhr = connectXHR(url, checkresult);
	}else{//增加专题
		var url = "json/plantManager-checkSubjectName.html?subjectName=" + name + "&idSubject=" + 0;
		xhr = null;
		xhr = connectXHR(url, checkresult);
	}
}
function checkresult(){
	if(xhr == null)return;
	if(xhr.readyState == 4 && xhr.status == 200) {
		var data = eval('(' + xhr.responseText + ')');
		
		if(data == 1){
			$( "#dialog" ).dialog( "open" );
		}else{
			document.getElementById("addsubject").submit();
		}
	}
}